package com.pad.dpscn.daag.sdk.common.message;

import java.util.List;
/**
 * 
 * com.pad.dpscn.daag.sdk.common.message  
 *  
 * <p>  
 * Description: 使用Builder模式
 * </p>  
 *  
 * @author yangdechao  
 * @since 2024年3月11日  
 * @version 1.0
 */
public class MqMessage {

	/**
	 * 数据主键
	 */
	private final List<String> primaryKeysName;
	/**
	 * RocketMQ topic名称
	 */
	private final String topic;
	/**
	 * DDL操作类型
	 */
	private final String operType;
	/**
	 * DDL表名
	 */
	private final String table;
	/**
	 * applicationName名称
	 */
	private final String serviceName;
	/**
	 * DDL执行SQL不带参数
	 */
	private final String operateSql;
	/**
	 * DDL执行SQL携带参数
	 */
	private final String paramsOperSql;
	/**
	 * DAO最终参数
	 */
	private final Object mapperMethodParamsData;

	/**
	 * 业务库中的数据
	 */
	private final Object dbData;

	/**
	 * 业务库查询条件
	 */
	private final String whereQueryCondition;
	
	/**
	 * 业务库查询条件
	 */
	private final Long operationTime;

	private MqMessage(Builder builder) {
		this.primaryKeysName = builder.primaryKeysName;
		this.topic = builder.topic;
		this.operType = builder.operType;
		this.table = builder.table;
		this.serviceName = builder.serviceName;
		this.operateSql = builder.operateSql;
		this.paramsOperSql = builder.paramsOperSql;
		this.mapperMethodParamsData = builder.mapperMethodParamsData;
		this.dbData = builder.dbData;
		this.operationTime = builder.operationTime;
		this.whereQueryCondition = builder.whereQueryCondition;
	}

	public Builder toBuilder() {
		return new Builder().topic(this.topic).operType(this.operType).primaryKeysName(this.primaryKeysName).table(this.table).serviceName(this.serviceName)
				.operateSql(this.operateSql).paramsOperSql(this.paramsOperSql)
				.mapperMethodParamsData(this.mapperMethodParamsData).dbData(this.dbData).operationTime(this.operationTime)
				.whereQueryCondition(whereQueryCondition);

	}

	public static class Builder {
		private List<String> primaryKeysName;
		private String topic;
		private String operType;
		private String table;
		private String serviceName;
		private String operateSql;
		private String paramsOperSql;
		private Object mapperMethodParamsData;
		private Object dbData;
		private Long operationTime;
		private String whereQueryCondition;

		public Builder primaryKeysName(List<String> primaryKeysName) {
			this.primaryKeysName = primaryKeysName;
			return this;
		}

		public Builder whereQueryCondition(String whereQueryCondition) {
			this.whereQueryCondition = whereQueryCondition;
			return this;
		}

		public Builder topic(String topic) {
			this.topic = topic;
			return this;
		}

		// 必要参数构造器的构造方法
		public Builder operType(String operType) {
			this.operType = operType;
			return this;
		}

		public Builder table(String table) {
			this.table = table;
			return this;
		}

		public Builder serviceName(String serviceName) {
			this.serviceName = serviceName;
			return this;
		}

		public Builder operateSql(String operateSql) {
			this.operateSql = operateSql;
			return this;
		}

		public Builder paramsOperSql(String paramsOperSql) {
			this.paramsOperSql = paramsOperSql;
			return this;
		}

		public Builder mapperMethodParamsData(Object mapperMethodParamsData) {
			this.mapperMethodParamsData = mapperMethodParamsData;
			return this;
		}

		public Builder dbData(Object dbData) {
			this.dbData = dbData;
			return this;
		}
		public Builder operationTime(Long operationTime) {
			this.operationTime = operationTime;
			return this;
		}

		// 构造返回目标对象
		public MqMessage builder() {
			return new MqMessage(this);
		}
	}

	public String getTopic() {
		return topic;
	}

	public String getOperType() {
		return operType;
	}

	public String getTable() {
		return table;
	}

	public String getServiceName() {
		return serviceName;
	}

	public String getOperateSql() {
		return operateSql;
	}

	public Object getMapperMethodParamsData() {
		return mapperMethodParamsData;
	}

	public String getParamsOperSql() {
		return paramsOperSql;
	}

	public Object getDbData() {
		return dbData;
	}

	public List<String> getPrimaryKeysName() {
		return primaryKeysName;
	}

	public String getWhereQueryCondition() {
		return whereQueryCondition;
	}

	public Long getOperationTime() {
		return operationTime;
	}
	
}